const { HelloRequest, HelloReply } = require('./greet_pb.js');
const { GreeterClient } = require('./greet_grpc_web_pb.js');

var client = new GreeterClient('https://localhost:5002');

var request = new HelloRequest();
request.setName('World');

client.sayHello(request, {}, (err, response) => {
    console.log(response.getMessage());
});

var metadata = { 'custom-header-1': 'value1' };
var stream = client.streamingFromServer(request, metadata);
stream.on('data', function(response) {
    console.log(response.getMessage());
});
stream.on('status', function(status) {
    console.log(status.code);
    console.log(status.details);
    console.log(status.metadata);
});
stream.on('end', function(end) {
    // stream end signal
});